<?php

class Application_Model_DbTable_Reply extends Zend_Db_Table_Abstract {

    protected $_name = 'reply';
	
	public function getAllReplies($id){
        $rows = $this->fetchAll("robotId = ".$id);
        return $rows;
	}
	
    public function getReply($robotId,$reply){
        $row = $this->fetchRow("reply='".$reply."' AND robotId =  '".$robotId."'");
        return $row;
	}
		
	public function createReply($robotId,$reply,$ct){
		$row = $this->createRow();
		$row->robotId = $robotId;
		$row->reply = $reply;
		$row->ct = $ct;
		$row->save();
		return $row;
	}
	
	public function updateReply($robotId,$reply,$num){
		$row = $this->getReply($robotId,$reply);
		$count = $row->ct;
		$count = $count + $num;
		$row->ct = $count;
		$row->save();
		return $row;
	}
}
